export const namespace = "stadiumPayroll";
import record from "@/pages/marketing/record";
// import { Image } from "antd";

export const calcColumns = (params) => {
  let { venueArr } = params;
  let enumlist = {};
  venueArr.forEach((v) => {
    enumlist[v.id] = {
      text: v.venueName,
    };
  });
  const columns = [
    {
      title: "手机号码",
      dataIndex: "tel",
      // hideInSearch: true
    },
    {
      title: "员工姓名",
      dataIndex: "userNickName",
    },
    {
      title: "所属场馆",
      dataIndex: "venueId",
      // hideInSearch: true,
      valueEnum: enumlist,
    },

    {
      title: "发放周期",
      dataIndex: "grantCycle",
      hideInSearch: true,
    },
    {
      title: "基本工资",
      dataIndex: "salaryTypeJson",
      hideInSearch: true,
      render: (_, record) => {
        let salary = JSON.parse(record.salaryTypeJson || "[]").filter(
          (type) => type.salary_type_name === "基本工资"
        );
        return <span>{salary.length ? salary[0].value : "-"}</span>;
      },
    },
    {
      title: "五险一金",
      dataIndex: "salaryTypeJson",
      hideInSearch: true,
      valueType: "money",
      render: (_, record) => {
        let salary = JSON.parse(record.salaryTypeJson || "[]").filter(
          (type) => type.salary_type_name === "五险一金"
        );
        return <span>{salary.length ? salary[0].value : "-"}</span>;
      },
    },
    {
      title: "课时工资",
      dataIndex: "courseSalary",
      hideInSearch: true,
    },
    {
      title: "业绩提成",
      dataIndex: "performanceSalary",
      hideInSearch: true,
    },
    {
      title: "应发工资",
      dataIndex: "username",
      hideInSearch: true,
      render: (_, record) => {
        let salarys = 0 + +record.courseSalary + +record.performanceSalary;
        JSON.parse(record.salaryTypeJson || "[]").forEach((type) => {
          if (type.count_method == 1) {
            salarys += +type.value;
          } else {
            salarys -= +type.value;
          }
        });
        return <span>{salarys}</span>;
      },
    },
  ];
  if (params?.operate) {
    columns.push(params?.operate);
  }
  return columns;
};
